<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改印章审批')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: jasny-bootstrap-css" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
	<style>
		.file-preview {
		    padding: 0;
		    margin-bottom: 0;
		    border-radius: 0;
		    border: none;
		}
		
		.krajee-default.file-preview-frame {
		    margin-right: 20px;
		    padding: 0;
		    border: none;
		    box-shadow: none;
		}
		
		.krajee-default.file-preview-frame:not(.file-preview-error):hover {
		    border: none;
		    box-shadow: none;
		}
		
		.krajee-default .file-footer-caption {
			margin-bottom: 0;
		}
		
		.krajee-default.file-preview-frame .file-thumbnail-footer {
		    height: auto;
		}
		
		.krajee-default .file-caption-info {
			width: auto;
		}
		
		.kv-upload-progress .progress {
			margin-top: 0;
		}
		
		.krajee-default.file-preview-frame .kv-file-content,
		.krajee-default .file-size-info,
		.krajee-default .file-upload-indicator,
		.file-input .kv-file-upload,
		.file-input .kv-file-zoom {
			display: none;
		}
		
		.file-input .kv-file-remove {
			position: absolute;
			top: 3px;
			right: -15px;
			height: 14px;
			padding: 0;
			margin: 0;
			border: none;
			background: none;
		}
		
		.file-input .kv-file-remove:active, 
		.file-input .kv-file-remove:focus {
			background: none;
			outline: none;
			box-shadow: none;
		}
		
		.file-input .kv-file-remove .glyphicon-trash {
			color: red;
		}
	</style>
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-yzsp-edit" th:object="${gcYzsp}">
            <input name="id" th:field="*{id}" type="hidden">
            <input type="hidden" id="zlwj" name="zlwj" th:value="*{zlwj}" />
            <input type="hidden" id="zlwjvo" name="zlwjvo" th:value="${zlwjvo}" />
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">文件名称：</label>
                <div class="col-sm-8">
                    <input name="name" th:field="*{name}" class="form-control" type="text" autoComplete="off" required>
                </div>
            </div>
            <div class="form-group"> 
	            <label class="col-sm-3 control-label is-required">公司：</label>
	           	<div class="col-sm-8">
	           		<select name="ztdw" class="form-control" th:with="type=${@dict.getType('sj_gongs')}" required>
	                   	<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
	               	</select>
	            </div>
            </div>
            <div class="form-group"> 
            	<label class="col-sm-3 control-label is-required">印章类型：</label>
                <div class="col-sm-8">
		            <select name="type" th:field="*{type}" class="form-control" th:with="type=${@dict.getType('gcgl_yztype')}" required>
		                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
		            </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">申请事由：</label>
                <div class="col-sm-8">
                    <textarea name="descs" class="form-control" required>[[*{descs}]]</textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">报送单位：</label>
                <div class="col-sm-8">
                	<input name="bsdw" th:field="*{bsdw}" class="form-control" type="text" autoComplete="off" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">申请人：</label>
                <div class="col-sm-8">
                    <input name="sqr" th:field="*{sqr}" class="form-control" type="text" autoComplete="off" required>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">申请日期：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="riq" th:value="${#dates.format(gcYzsp.riq, 'yyyy-MM-dd')}" class="form-control" placeholder="yyyy-MM-dd" type="text" autoComplete="off" required>
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label is-required">用印数量：</label>
                <div class="col-sm-8">
                    <input name="shul" th:field="*{shul}" class="form-control" type="text" autoComplete="off" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">合同文件：</label>
                <div class="col-sm-8" style="margin-top: 8px;" id="zlwjlink">
                </div>
            </div>
            <div class="form-group" th:if="${gcYzsp.status} eq 0">
	            <label class="col-sm-3 control-label font-noraml">合同文件：</label>
	            <div class="col-sm-8">
	            	<div class="file-loading">
		            	<input id="multipleFile" name="files" type="file" multiple>
		        	</div>
	            </div>
            </div>
        </form>
    </div>
    <div class="row">
        <div class="col-sm-offset-5 col-sm-10">
            <button th:if="${gcYzsp.status} eq 0" type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>保 存</button>&nbsp;
            <button type="button" class="btn btn-sm btn-danger" onclick="closeItem()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: jasny-bootstrap-js" />
    <script th:src="@{/ruoyi/base64.min.js?v=20231208}"></script>
    <th:block th:include="include :: bootstrap-fileinput-js" />
    <th:block th:include="include :: bootstrap-suggest-js" />
    <th:block th:include="include :: bootstrap-typeahead-js" />
    <script th:inline="javascript">
        var prefix = ctx + "gcgl/yzsp";
        $("#form-yzsp-edit").validate({
            focusCleanup: true
        });
        
        $(function() {
			var zilwj = $("#zlwjvo").val();
        	
        	var n=zilwj.split(",");
        	for(var i=0;i<n.length;i++){
//         		var url = "http://lkgnews.cn:8012/onlinePreview?url="+encodeURIComponent(Base64.encode(n[i]));
        		var url = n[i];
        		$("#zlwjlink").append("<a href='"+url+"' target='_blank' >"+n[i]+"</a><br>");
        	}
        	
        	// 多图上传
	       $("#multipleFile").fileinput({
	           uploadUrl: "/gcgl/yzsp/uploads",
	           uploadAsync: false,
	           showClose: false,
	           showCancel: false,
	           dropZoneEnabled: false,
	           buttonLabelClass: ''
	       }).on('filebatchuploadsuccess', function (event, data, previewId, index) {
	       	var rsp = data.response;
	           log.info("reutrn fileNames：" + rsp.fileNames)
			   $("#zlwj").val(rsp.fileNames);
	       }).on('fileremoved', function (event, id, index) {
	           $("input[name='" + event.currentTarget.id + "']").val('')
	       })
        });

        function submitHandler() {
            if ($.validate.form()) {
            	
//             	var form = document.getElementById("form-yzsp-edit");
//                 var file = new FormData(form);
//                 $.ajax({
//                     url: "/gcgl/yzsp/edit",
//                     type: "POST",
//                     processData:false,
//                     contentType:false,
//                     //重要部分，data的传的是整个表单，不用大括号包裹；不用自定义变量名
//                     data:file,
//                     success: function (date) {
//                     	$.modal.close();
//                     	refreshTab();
//                     },
//                     error: function (date) {
//                     	$.modal.close();
//                     	refreshTab();
//                     }
//                 })
            	
                $.operate.saveTab(prefix + "/edit", $('#form-yzsp-edit').serialize());
            }
        }

        $("input[name='riq']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

    </script>
</body>
</html>